﻿using System;
using System.Data;
using System.Net;
using FluentPS.Impersonation;
using FluentPS.Services;
using FluentPS.WebSvcProject;

namespace FluentPS.WebServiceProxy.Impl
{
    public class ProjectProxy : Project, IProjectProxy
    {
        private IPsiContextService _psiContextService;

        public ProjectProxy(IPsiContextService psiContextService)
        {
            _psiContextService = _psiContextService;
        }

        public DataSet ReadProjectEntities(Guid projectUid, int projectEntityType, DataStoreEnum dataStore)
        {
            return base.ReadProjectEntities(projectUid, projectEntityType, dataStore);
        }

        public void QueueUpdateProject(Guid jobUid, Guid sessionUid, DataSet dataset, bool validateOnly)
        {
            base.QueueUpdateProject(jobUid, sessionUid, (ProjectDataSet)dataset, validateOnly);
        }

        protected override WebRequest GetWebRequest(Uri uri)
        {
            var webRequest =  base.GetWebRequest(uri);
            ImpersonationHelper.PrepareWebRequest(webRequest, _psiContextService);
            return webRequest;
        }
    }
}
